// 引入路由组件
// import Home from '@/pages/Home'
// import Search from '@/pages/Search'
// import Login from '@/pages/Login'
// import Register from '@/pages/Register'
// import Detail from '@/pages/Detail'
// import AddCarSuccess from '@/pages/AddCartSuccess'
// import ShopCart from '@/pages/ShopCart'
// import Trade from '@/pages/Trade'
// import Pay from '@/pages/Pay'
// import PaySuccess from '@/pages/PaySuccess'
// import Center from '@/pages/Center'
// // 引入二级路由组件
// import MyOrder from '@/pages/Center/myOrder'
// import GroupOrder from '@/pages/Center/groupOrder'

// const foo = ()=> import ('@/pages/Home')

// 路由配置信息
export default [
    {
        path: "/home",
        component: ()=> import ('@/pages/Home'),
        meta: { show: true }
    },
    {
        name: 'search',
        path: "/search/:keyword?",
        component: ()=> import ('@/pages/Search'),
        meta: { show: true }
    },
    {
        path: "/login",
        component: ()=> import ('@/pages/Login'),
        meta: { show: false }
    },
    {
        path: "/register",
        component: ()=> import ('@/pages/Register'),
        meta: { show: false }
    },
    {
        path: "/detail/:skuid",
        component: ()=> import ('@/pages/Detail'),
        meta: { show: true }
    },
    {
        path: "/addcartsuccess",
        name: "addcartsuccess",
        component: ()=> import ('@/pages/AddCartSuccess'),
        meta: { show: true }
    },
    {
        path: "/shopcart",
        name: "shopcart",
        component: ()=> import ('@/pages/ShopCart'),
        meta: { show: true }
    },
    {
        path: "/trade",
        name: "trade",
        component: ()=> import ('@/pages/Trade'),
        meta: { show: true },
        // 路由独享守卫
        beforeEnter:(to,from,next)=>{
            // 去交易页面，必须从购物车而来
            if(from.path=='/shopcart'){
                next()
            }else{
                // 其他的路由组件而来，停留在当前
                next(false)
            }
        }
    },
    {
        path: "/pay",
        name: "pay",
        component: ()=> import ('@/pages/Pay'),
        meta: { show: true },
        beforeEnter:(to,from,next)=>{
            if(from.path=='/trade'){
                next()
            }else{
                next(false)
            }
        }
    },
    {
        path: "/paysuccess",
        name: "paysuccess",
        component: ()=> import ('@/pages/PaySuccess'),
        meta: { show: true }
    },
    {
        path: "/center",
        name: "center",
        component: ()=> import ('@/pages/Center'),
        meta: { show: true },
        // 二级路由组件
        children: [
            {
                path: 'myorder',
                component: ()=> import ('@/pages/Center/myOrder')
            },
            {
                path: 'groupOrder',
                component: ()=> import ('@/pages/Center/groupOrder')
            },
            {
                path: '/center',
                redirect: '/center/myorder'
            }
        ]
    },


    // 重定向，在项目跑起来的时候，访问 /，立马让他定向到首页
    {
        path: '*',
        redirect: '/home'
    }
]